<!--
* description: 采购管理-备货单查询
* author: hzm
* createdDate: 2021-1-21
-->
<template>
  <div class="app-container app-container-table">
    <one-table-template
      ref="multipleTable"
      :dynamic-buttons="tableButtons"
      :dynamic-components="tableComponents"
      :dynamic-api-config="dynamicApiConfigs"
      :dynamic-table-cols="tableCols"
      :dynamic-form-fields="formField"
      :dynamic-is-show-select="false"
      :dynamic-is-init-table="true"
      :dynamic-is-fix-choose="false"
      :dynamic-is-fix-index="false"
      :dynamic-api-style="'restful'"
    />
    <!-- <edit
      :key="editPopupsKey"
      :dynamic-edit-row-data="editRowData"
      :popups-visible="editPopupsVisible"
      :dynamic-api-style="'restful'"
      @close="close"
    /> -->
  </div>
</template>

<script>
import { oneTableWithViewTemplateMixins } from "@/components/mixins/oneTableWithViewTemplateMixins";
import OneTableTemplate from "@/components/templates/oneTable";
import { orgApis } from "@/api/paSparePartsManagement";
import { exportExcel } from '@/utils/getTimeString.js'

export default {
  name: "pickingList",
  components: {
    OneTableTemplate,
    // Edit: () => import('./edit')
  },
  mixins: [oneTableWithViewTemplateMixins],
  data() {
    return {
      dynamicApiConfigs: orgApis.findSaleStockListQueryPage,
      // 动态生成网格列
      tableCols:
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path] &&
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path].tableCols &&
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path].tableCols
          .length > 0
          ? this.$ConfigCache.CacheConfig.cacheData[this.$route.path].tableCols
          : [
              {
                prop: "dlrCode",
                label: "网点编码",
                align: "center",
              },
              {
                prop: "dlrShortName",
                label: "网点名称",
                align: "center",
              },
              {
                prop: "purOrderCode",
                label: "订单号",
                align: "center",
              },
              {
                prop: "dlrPartNo",
                label: "备件号",
                align: "center",
              },
              {
                prop: "partName",
                label: "备货名称",
                align: "center",
              },
              {
                prop: "purQty",
                label: "备货数量",
                align: "center",
              },
              {
                prop: "purPrice",
                label: "备货价格",
                align: "center",
              },
              {
                prop: "purAmount",
                label: "备货金额",
                align: "center",
              },
              {
                prop: "stockUpStatusCn",
                label: "备货状态",
                align: "center",
              },
              {
                prop: "orderTime",
                label: "备货日期",
                align: "center",
              },
              {
                prop: "supplierId",
                label: "备货供应商",
                align: "center",
              },
              {
                prop: "orderTypeDirectCn",
                label: "是否直送",
                align: "center",
              },
            ],
      tableComponents:
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path] &&
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path]
          .tableComponents &&
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path]
          .tableComponents.length > 0
          ? this.$ConfigCache.CacheConfig.cacheData[this.$route.path]
              .tableComponents
          : [
              // 库存状态
              {
                compKey: "compKey1",
                labelName: "网点编码：",
                codeField: "dlrCode",
                component: () => import("@/components/org/commonInput"),
                type: "inputText",
                isMust: true,
                span: 6,
              },
              // 车辆状态
              {
                compKey: "compKey2",
                labelName: "网点名称：",
                codeField: "dlrShortName",
                component: () => import("@/components/org/commonInput"),
                type: "inputText",
                isMust: true,
                span: 6,
              },
              // 入库仓库
              {
                compKey: "compKey3",
                labelName: "订单号：",
                codeField: "purOrderCode",
                component: () => import("@/components/org/commonInput"),
                type: "inputText",
                isMust: true,
                span: 6,
              },
              {
                compKey: "compKey4",
                labelName: "订单类型：",
                codeField: "purOrderType",
                textField: "lookupValueName",
                customObj: {
                  api: orgApis.queryOrderType,
                },
                component: () => import("@/components/org/commonSelect"),
                type: "dropdownList",
                isMust: true,
                span: 6,
              },
              // VIN码
              {
                compKey: "compKey5",
                labelName: "备货单号：",
                codeField: "stockUpCode",
                component: () => import("@/components/org/commonInput"),
                type: "inputText",
                isMust: false,
                span: 6,
              },
              {
                compKey: "compKey6",
                labelName: "订货日期：",
                codeField: "startDate,endDate",
                component: () => import("@/components/org/datePicker/andtDatePicker"),
                type:'YYYY-MM-DD',
                dataToObject:{timer:true,thirtyTime:true,hhmmss: true},
                format: 'yyyy-MM-dd',
                dateOptionsType: '0',
                isMul: false,
                isMust: false,
                span: 6,
              },
              {
                compKey: "compKey7",
                labelName: "备货仓库：",
                codeField: "warehouseId",
                textField: "warehouseName",
                customObj: {
                  api: orgApis.queryWareHouseName,
                  defOptionFields:['warehouseId','warehouseName']
                },
                component: () => import("@/components/org/commonSelect"),
                type: "dropdownList",
                isMust: false,
                span: 6,
              },
            ],
      tableButtons: [
        {
          conmpKey: "btenKey1",
          type: "primary",
          size: "small",
          name: 'search',
          text: "查询",
          clickEvent: () => this.queryTable(1),
          position: "right",
        },
        {
          conmpKey: 'btenKey3',
          type: '',
          size: 'small',
          clickEvent: () => this.export(),
          text: this.$t('sys.button.export'),
          name: 'export',
          position: 'right' // 导出
        },
        {
          conmpKey: "btenKey2",
          type: "",
          size: "small",
          text: this.$t("sys.button.reset"),
          name: 'reset',
          clickEvent: () => this.reset(),
          position: "right",
        },
      ],
      formField: 
      {
        dlrCode: "",
        dlrShortName: "",
        purOrderCode: "",
        purOrderType: "",
        stockUpCode: "",
        startDate: "",
        endDate: "",
        warehouseId: "",
      }
    };
  },
  methods: {
     export(){
      exportExcel(this.formField, orgApis.exportSaleStockListQueryDlr.APIUrl, orgApis.exportSaleStockListQueryDlr.ServiceCode, '备货单查询')
    },
    // 编辑获取数据
    // edit(index) {
    //   this.editPopupsVisible = true
    //   console.log(index,'index');
    //   // this.editRowData = this.$utils.deepCopy(this.$refs['multipleTable'].list[index])
    // }
    // close(aa) {
    //   console.log(aa,'aa');
    // }
  },
  mounted() {
    this.queryTable(1)
  },
};
</script>

<style>
</style>
